import flash.events.Event;
import flash.events.EventDispatcher;

class CircleModel extends AVerletModel
{
  private var _radius:Float;
  private var _type:String;
  public var Alpha:Float;
  public var Fading:Int;
  public var FadeRate:Int;
  public var invincible:Int;
  public var InvincibilityLength:Int;

  public function new
    (type:String,?radius:Float = 30, ?color:Int = 0x999999,?inFadeRate:Int = 100)
  {
    super();
    _type = type;
    this.radius = radius;
    this.color = color;
    FadeRate = inFadeRate;
    Fading = 0;
    Alpha = 1;
    InvincibilityLength = 100;
  }

  public override function update()
  {
    super.update();
    if(Fading > 0)
      {
      Fading++;
      Alpha=1-(Fading/FadeRate);
      if(Alpha < 0)
	{Alpha = 0;}
      }
    if(invincible != 0)
      {invincible++;}
    if(invincible > InvincibilityLength)
      {
      invincible = 0;
      }
    visible = (invincible % 4 != 1);
    
    
  }

  public function getType()
  {
    return _type;
  }
  //radius
  public var radius(getRadius,setRadius):Float;
  public function getRadius():Float
  {
    return _radius;
  }
  public function setRadius(value:Float):Float
  {
    _radius = value;
    this.width = Std.int(radius * 2);
    this.height = Std.int(radius * 2);
    return _radius;
  }
}